package com.amazon.shop.service.impl;

import cn.hutool.extra.mail.MailAccount;
import cn.hutool.extra.mail.MailUtil;
import com.alibaba.fastjson.JSONObject;
import com.amazon.shop.bean.dto.SendEmailForm;
import com.amazon.shop.bean.entity.Emailmodel;
import com.amazon.shop.bean.entity.Evalform;
import com.amazon.shop.bean.entity.Store;
import com.amazon.shop.bean.vo.Ret;
import com.amazon.shop.mapper.EmailmodelMapper;
import com.amazon.shop.service.IEmailmodelService;
import com.amazon.shop.service.IStoreService;
import com.amazon.shop.service.IEvalformService;
import com.amazon.shop.util.ResultUtil;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.apache.logging.log4j.LogManager;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author lzj
 * @since 2021-03-15
 */
@Service
public class EmailmodelServiceImpl extends ServiceImpl<EmailmodelMapper, Emailmodel> implements IEmailmodelService {

    @Autowired
    private IEmailmodelService emailmodelService;

    @Autowired
    private AsyncSendEmail asyncSendEmail;

    @Override
    public Ret send(SendEmailForm sendEmailForm) {
        List<Integer> evalformIds = sendEmailForm.getEvalformIds();
        Emailmodel emailmodel = emailmodelService.getById(sendEmailForm.getEmailModelId());
        asyncSendEmail.sendEmail(evalformIds,emailmodel);
        return ResultUtil.success();
    }

}
